package com.haruhi.example;

import com.haruhi.ws.WsListener;

import javax.websocket.CloseReason;
import javax.websocket.EndpointConfig;
import javax.websocket.Session;

/**
 * 自定义ServerEndpoint 默认是com.haruhi.ws.server.ServerEndpoint
 */
public class MyServerEndpoint implements WsListener {
    @Override
    public void onOpen(Session session, EndpointConfig endpointConfig) {
        System.out.println("自定义endpoint -> 收到客户端连接");
    }

    @Override
    public void onError(Session session, Throwable throwable) {
        System.out.println("自定义endpoint -> 客户端连接异常" + throwable.getMessage());
    }

    @Override
    public void onClose(Session session, CloseReason closeReason) {
        System.out.println("自定义endpoint -> 客户端连接断开");
    }

    @Override
    public void onMessage(Session session, String msg) {
        System.out.println("自定义endpoint -> 收到客户端消息："+msg);
//        MessageQueue.offer(new Message(session,msg, MessageSource.CLIENT));
    }
}
